﻿using ClassLibrary1;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        //确定
        protected void Ok_Click(object sender, EventArgs e)
        {

            bool use = tbPwd.Text == tbPwdOk.Text;
            if (tbUsersName.Text == "" || tbPwd.Text == "")
            {
                Hint.Text = "账号或密码不能为空";
                           
            }
            else
            {
                if (use)
                {
                  
                    var sql = string.Format("insert into Users(Username,Password)values('{0}','{1}')",tbUsersName.Text,tbPwd.Text);
                     var tur=Dbhelper.AddOrUpdateOrDelete(sql);
                    if (tur>0)
                    {
                        Hint.Text = "注册成功";
                        Response.Redirect("Login.aspx");
                    }
                    else
                    {
                        Hint.Text = "注册失败";
                    }
                   
                }
                else
                {
                    Hint.Text = "两次输入的密码不一致";
                }
            }
        }

        //取消
        protected void Cancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("Login.aspx");
        }
    }
}